import { Form, Input, Button, message } from 'antd';

import AdminsApi from "../../../api/admins";
// eslint-disable-next-line
export default () => {
  const onFinish = async (values) => {
    const { adminName, adminPassword, phone } = values;
    const status = await AdminsApi.reg({ adminName, adminPassword, phone });
    if (status) {
      message.success("添加成功", 1, () => {
        
      });
    }
  };
  const onFinishFailed = (errorInfo) => {
    console.log('Failed:', errorInfo);
  };
  return (
    <Form
      style={{
        marginTop: "30px"
      }}

      name="basic"
      labelCol={{
        span: 8,
      }}
      wrapperCol={{
        span: 8,
      }}
      initialValues={{
        remember: true,
      }}
      onFinish={onFinish}
      onFinishFailed={onFinishFailed}
      autoComplete="off"
    >
      <Form.Item
        label="adminName"
        name="adminName"
        rules={[
          { required: true, },
        ]}
      >
        <Input />
      </Form.Item>

      <Form.Item
        label="adminPassword"
        name="adminPassword"
        rules={[
          { required: true, },
        ]}
      >
        <Input />
      </Form.Item>

      <Form.Item
        label="phone"
        name="phone"
        rules={[
          {
            required: true,
          },
        ]}
      >
        <Input />
      </Form.Item>
      
      <Form.Item
        wrapperCol={{
          offset: 10,
          span: 12,
        }}
      >
        <Button type="primary" htmlType="submit">
          Submit
        </Button>
      </Form.Item>
    </Form>
  )
}